# encoding=utf-8
import redis

pool1 = {"host": "127.0.0.1", "port": 6379, "database": 15, "password": "lyf000000"}
pool2 = {"host": "192.168.15.128", "port": 30379, "database": 15, "password": "lyf000000"}

conn1 = redis.ConnectionPool(host = pool1["host"], port = pool1["port"], db = pool1["database"], password = pool1["password"])
cache1 = redis.Redis(connection_pool = conn1, decode_responses = True, charset = 'UTF-8', encoding = 'UTF-8')

conn2 = redis.ConnectionPool(host = pool2["host"], port = pool2["port"], db = pool2["database"], password = pool2["password"])
cache2 = redis.Redis(connection_pool = conn2, decode_responses = True, charset = 'UTF-8', encoding = 'UTF-8')


def get_book_list():
    hgetall = cache1.hgetall("book_list").items()
    for i in hgetall:
        key = str(i[0], encoding = "utf-8")
        value = str(i[1], encoding = "utf-8")
        # print(key, value)
        cache2.hset("book_list", key, value)


def get_area():
    lrange = cache1.lrange("area", 0, cache1.llen("area"))
    for i in lrange:
        s = str(i, encoding = "utf-8")
        # print(s)
        cache2.lpush("area",s)

get_area()